package com.gt.quality.system.service.impl;

import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gt.quality.config.SpringBeanUtil;
import com.gt.quality.system.entity.FileExportTemplate;
import com.gt.quality.system.mapper.FileExportTemplateMapper;
import com.gt.quality.base.pojo.BaseLimitRequest;
import com.gt.quality.system.service.FileExportTemplateService;
import jakarta.annotation.Resource;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.support.TransactionTemplate;

import java.util.List;

/**
 * 文件导入模板(FileExportTemplate)表服务实现类
 *
 * @author makeJava
 * @since 2025-01-04 22:14:07
 */
@Service("fileExportTemplateService")
public class FileExportTemplateServiceImpl extends ServiceImpl<FileExportTemplateMapper, FileExportTemplate> implements FileExportTemplateService {

    @Resource
    private FileExportTemplateMapper fileExportTemplateMapper;


    /**
     * Description:  分页查询
     *
     * @param limitRequest 分页查询参数
     * @author: makeJava
     * @date: 2025-01-04 22:14:07

     */
    @Override
    public IPage<FileExportTemplate> queryLimitPage(BaseLimitRequest<FileExportTemplate> limitRequest) {
        FileExportTemplate requestBody = limitRequest.getRequestBody();
        IPage<FileExportTemplate> page = getByPageParam(limitRequest);
        JSONObject thisObj = JSONObject.from(requestBody);
        QueryWrapper<FileExportTemplate> queryWrapper = queryWrapperBuilder(thisObj, limitRequest);
        return fileExportTemplateMapper.selectPage(page, queryWrapper);
    }

    /**
     * Description:  批量新增优化版
     *
     * @param entityList entityList
     * @author: makeJava
     * @date: 2025-01-04 22:14:07
     * @return: Integer
     */
    @Override
    public Integer saveBatchByEasyBaseMapper(List<FileExportTemplate> entityList) {

        return fileExportTemplateMapper.insertBatchSomeColumn(entityList);
    }


    /**
     * 往上传递 SqlSessionFactory
     *
     * @return SqlSessionFactory
     */
    @Override
    public SqlSessionFactory getSqlSessionFactory() {
        return super.getSqlSessionFactory();
    }

    /**
     * 往上传递 Mapper
     *
     * @return Mapper
     */
    @Override
    public Class<?> getThisMapperClass() {
        return FileExportTemplateMapper.class;
    }

    /**
     * 往上传递 Transaction
     *
     * @return Transaction
     */
    @Override
    public TransactionTemplate getSpringTx() {
        return SpringBeanUtil.getBean(TransactionTemplate.class);
    }
}


